var tableData = {
	url : ctp + "/workerController/workerSearch.shtml",
	propertys : [ "NAME", "AGE", "SEX" ,"NATIVE","WORKTYPE","GROUPNAME","REGISTEREDAGE","TEL","CONTRACTSTATE" ],
	hrefs : [ [ "function=workerUpdate", "recId=REC_ID", "详情", null ]],
	css:[null,null,null,null,null,null,null,null,"[CONTRACTSTATE_CHAR][2=color:red;]"],//不同值的样式
	//maxLength:["TASKNAME=15"],
	hidden : [ "jobno=JOBNO", "userLoginCode=TEL" ],
	checkBox:["REC_ID",true],
	startLoad : function() {
		getListData(this);
	}
};


function searchData(curr) {
	setTagAndValue("form1", "curr", curr);
	tableData.startLoad();
}
$(document).ready(function() {
	getWorkerType();
	//页面中下拉框的渲染
	/*$('select').SumoSelect({
	placeholder: '请选择',
    csvDispCount: 4,
    captionFormat: '{0} Selected',
    forceCustomRendering: false,
    outputAsCSV : false,
    okCancelInMulti: false, 
    triggerChangeCombined : true
	});*/
	//页面加载时，加载列表
	searchData();

});


function workerDel() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要删除的记录！");
		return false;
	}
	jconfirm("del('" + recIds + "')", "是否要删除所选记录？");
}
function del(recIds) {
	$.ajax({
		url : ctp + "/workerController/workerDelete.shtml",
		data : {
			recIds : recIds,
			jobnos : getCheckIds(null,'jobno')
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result == "") {
				jalert9("删除成功！");
				var curr = "1";
				if ($("#form1").find("#curr").length > 0) {
					curr = $("#curr").val();
				}
				searchData(curr);
			} else {
				jalert(result);
			}
		}
	});
}

// 修改
function workerUpdate(recId) {
	location.href=ctp +"/workerController/workerUpdate.shtml?recId="+ recId;
}

//修改
function workerDetail(recId) {
	location.href=ctp +"/workerController/workerDetail.shtml?recId="+ recId;
}
// 新增
function workerAdd() {
	location.href=ctp + "/workerController/workerAdd.shtml";
}


// 重置密码
function resetPwd() {
	var recIds = getCheckIds(null, "userLoginCode");
	if (recIds == '') {
		jalert("请选择记录！");
		return false;
	}
	jconfirm("doReset('" + recIds + "')", "确定要重置所选用户的密码吗？");
}

function doReset(recIds) {
	$.ajax({
		url : ctp + "/workerController/resetPwd.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			jalert9(result);
			setTimeout(function() {
				searchData();
			}, 1000);
		}
	});
}


function workerDisable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要停用的用户！");
		return false;
	}
	jconfirm("Disable('" + recIds + "')", "是否要停用所选的用户？");
}
function Disable(recIds) {
	$.ajax({
		url : ctp + "/workerController/workerDisable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("停用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("停用用户失败！");
			}
		}
	});
}

function workerEnable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要启用的用户！");
		return false;
	}
	jconfirm("Enable('" + recIds + "')", "是否要启用所选的用户？");
}
function Enable(recIds) {
	$.ajax({
		url : ctp + "/workerController/workerEnable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("启用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("启用用户失败！");
			}
		}
	});
}


//导出系统用户
function workerExp(recId){
	var formSerialize =$("#form1").serialize();
	jconfirm("exportWorker('"+formSerialize+"')","确认要导出工人数据吗？");	
}
function exportWorker(formSerialize){
	location.href=ctp+"/workerController/exportWorker.shtml?"+formSerialize;
}


//用户信息导入界面跳转
function sysworkerImportpage(){
	dialogWin(550,450,ctp+"/workerController/sysworkerImportpage.shtml","用户信息导入");
}


function getWorkerType() {
	$.ajax({
		url : ctp + "/sysdictController/getDictListByType.shtml",
		data : {
			dicType : 'WORKER_TP'
		},
		type : "POST",
		cache : false,
		dataType : "json",
		success : function(data) {
			var list = data.list;
			var $str = '';
			$str += '<option value="">全部</option>';
			for (var i = 0; i < list.length; i++) {
				var l = list[i];
				$str += '<option value="' + l.rec_value + '">' + l.rec_value
						+ '</option>';
			}
			$('#workeType').html($str);
		}
	});
}























